package com.project.projectdemo;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.project.projectdemo.utils.ResultUtils;


@ControllerAdvice
public class GlobalExceptionHandler {

	Logger logger = LoggerFactory.getLogger("Logger");
	
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public Map handler(Exception e){
		logger.error(e.getMessage());
//		UnifiedException unifiedException = new UnifiedException(e);
//		throw unifiedException;
		e.printStackTrace();
//		logger.error(unifiedException.getMessage());
//		return ResultUtils.getResultMap(ResultUtils.FAIL, unifiedException.getMessage());
		return ResultUtils.getResultMap(ResultUtils.FAIL, e.getMessage());
	}
}
